<?php echo $this->render('./includes/header.phtml');?>
<?php echo $this->render('./includes/fix_top_menu.phtml');?>
	<div id="container" class="row-fluid">
		<?php echo $this->render('./includes/menu.phtml');?>
		<script language="javascript" type="text/javascript">
		<!--
		function popitup(url) {
			newwindow=window.open(url,'Your Tour Map','height=500,width=700');
			if (window.focus) {newwindow.focus()}
			return false;
		}
		
		// -->
		</script>
		<div id="main-content">
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<h3 class="page-title">
							Quản lí nhóm  <small></small>
						</h3>
					</div>
				</div>
							<div class="row-fluid">
					<div class="span12">
						<div class="widget">
							<div class="widget-title">
								<h4>
									<i class="icon-reorder"></i>Tổng số nhóm : <?php echo $this->total_tour;?>
								</h4>
							</div>
							<div class="widget-body">
								<?php echo $this->render('./includes/display_alert_message.phtml');?>
								<table class="table table-striped table-bordered" id="sample_1">
									<thead>
										<tr>
											<th>Tên </th>
											<th class="hidden-phone">Tạo bởi </th>
											<th class="hidden-phone">Địa điểm check in </th>
											<th class="hidden-phone">Thời gian </th>
											<th class="hidden-phone">Giới hạn thành viên </th>
											<th class="hidden-phone">Địa điểm bắt đầu </th>
											<th class="hidden-phone">Địa điểm kết thúc </th>
											<th class="hidden-phone span3 "></th>
										</tr>
									</thead>
									<tbody>
									<?php 
									if(count($this->arrTour) != 0) {
									$iCountTour = 0;
									foreach ($this->arrTour as $tour) {?>
										<tr class="odd gradeX">
											<td><?php echo $tour['name']; ?></td>
											<td class="hidden-phone">
												<?php if(isset($this->arrUser[$iCountTour][0]['username'])) {?>
												<?php echo $this->arrUser[$iCountTour][0]['username'];?>
												<?php }?>
											</td>
											<td class="hidden-phone"><?php echo count($this->arrLoc[$iCountTour]);?></td>
											<td class="center hidden-phone"><?php echo  !isset($tour['start_date']) ? "" : $tour['start_date']; ?> <?php echo  !isset($tour['end_date']) ? "" : " → ".$tour['end_date']; ?></td>
											<td class="hidden-phone"><?php echo $tour['limited_user'];?></td>
											<td class="hidden-phone">
												<?php if(isset($this->arrStartLoc[$iCountTour][0]['name'])) {?>
												<?php echo $this->arrStartLoc[$iCountTour][0]['name'];?>
												<a class="btn btn-mini btn-success" href="<?php echo $this->baseUrl('/location/map/?loc_id='.$this->arrStartLoc[$iCountTour][0]['location_id']);?>" onclick="return popitup('<?php echo $this->baseUrl('/location/map/?loc_id='.$this->arrStartLoc[$iCountTour][0]['location_id']);?>')"><i class="icon-globe"></i> Map</a>
												<?php }?>
											</td>
											<td class="hidden-phone">
												<?php if(isset($this->arrEndLoc[$iCountTour][0]['name'])) {?>
												<?php echo $this->arrEndLoc[$iCountTour][0]['name'];?>
												<a class="btn btn-mini btn-success" href="<?php echo $this->baseUrl('/location/map/?loc_id='.$this->arrEndLoc[$iCountTour][0]['location_id']);?>" onclick="return popitup('<?php echo $this->baseUrl('/location/map/?loc_id='.$this->arrEndLoc[$iCountTour][0]['location_id']);?>')"><i class="icon-globe"></i> Map</a>
												<?php }?>
											</td>
											<td class="hidden-phone">
												<a href="#myModal<?php echo  $tour['tour_id']; ?>"
										role="button" class="btn btn-primary" data-toggle="modal">Chi tiết </a>
										<div id="myModal<?php echo  $tour['tour_id']; ?>" class="modal hide fade" tabindex="-1"
										role="dialog" aria-labelledby="myModalLabel<?php echo  $tour['tour_id']; ?>"
										aria-hidden="true">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h3 id="myModalLabel2"><?php echo  $tour['name']; ?></h3>
										</div>
										<div class="modal-body">
											<p><span class="span3">Tạo bởi  : </span> <span class="span9">
											<?php if(isset($this->arrUser[$iCountTour][0]['username'])) {?>
												<?php echo $this->arrUser[$iCountTour][0]['username'];?>
												<?php }?>
											</span></p>
											<p><span class="span3">Mô tả  : </span> <span class="span9"><?php echo  $tour['description']; ?></span></p>
											<p><span class="span3">Thời gian  : </span> <span class="span9"><?php echo  !isset($tour['start_date']) ? "" : $tour['start_date']; ?> <?php echo  !isset($tour['end_date']) ? "" : " → ".$tour['end_date']; ?></span></p>
											<p><span class="span3">Giới hạn thành viên  : </span> <span class="span9"><?php echo  $tour['limited_user']; ?></span></p>
											<p><span class="span3">Trạng thái  : </span> <span class="span9"><?php if($tour['status'] == 0) echo "Sắp đi "; elseif($tour['status'] == 1) echo "Đang đi "; else echo "Đã đi "; ?></span></p>
											<p><span class="span3">Quyền riêng tư  : </span> <span class="span9"><?php echo  $tour['private'] == 0 ? "Công khai " : "Cá nhân "; ?></span></p>
											<?php if(isset($this->arrStartLoc[$iCountTour][0]['name'])) {?>
											<p><span class="span3">Địa điểm bắt đầu  : </span> <span class="span9">
												<?php echo $this->arrStartLoc[$iCountTour][0]['name'];?>
												</span></p>
											<?php }?>
											<?php if(isset($this->arrEndLoc[$iCountTour][0]['name'])) {?>
											<p><span class="span3">Địa điểm kết thúc  : </span> <span class="span9">
												<?php echo $this->arrEndLoc[$iCountTour][0]['name'];?>
												</span></p>
											<?php }?>
											<p><span class="span3">Đ.điểm check in  (<?php echo count($this->arrLoc[$iCountTour]);?>) : </span> 
												<span class="span9">
												
													<?php if(isset($this->arrLoc[$iCountTour]) && count($this->arrLoc[$iCountTour] != 0)) {?>
													<?php foreach ($this->arrLoc[$iCountTour] as $loc) {?>
													→ <?php echo $loc[0]['name'];?> <br/>
													<?php }?>
													<?php }?>
												</span>
											</p>
											<?php if(count($this->arrPhoto[$iCountTour]) != 0) {?>
											<div><div class="span3">Ảnh  : </div> 
												<div class="span9">
													
													<?php $iCountPhoto = 0;?>
													<?php foreach ($this->arrPhoto[$iCountTour] as $photo) {?>
													
													<img alt="" src="<?php echo UPLOAD_PHOTO_DIRECTORY.$photo['photo_link'];?>" style="width: 150px; height: 100px; margin: 5px;">
													
													<?php $iCountPhoto++;?>
													
													<?php }?>
													
												</div>
											</div>
											<?php }?>
										</div>
										<div class="modal-footer">
											<button data-dismiss="modal" class="btn btn-primary">OK</button>
										</div>
									</div>
									<a href="<?php echo $this->baseUrl('/tour/?delete=1&tour_id='.$tour['tour_id']);?>" class="btn btn-danger" title="Xoá " onclick="return confirm('Xoá nhóm?');"> <i class="icon-trash"></i> Xoá </a>
												</td>
										</tr>
										<?php 
										$iCountTour++;
										}
										}?>
									</tbody>
								</table>
								<?php if(count($this->arrTour) != 0) {?>
 								<?php echo $this->paginationControl($this->arrTour, 'Sliding' , './includes/pagination.phtml'); ?>
 								<?php }?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php echo $this->render('./includes/footer.phtml');?>
